//logs.js
Page(
  {
    data: {
      hidden:true,
      count: 1,
      length: 7,
      numberArray: [1, 2, 3, 4],
      items: [
        { name: 'USA', value: '美国' },
        { name: 'CHN', value: '中国', checked: 'true' },
        { name: 'BRA', value: '巴西' },
        { name: 'JPN', value: '日本' },
        { name: 'ENG', value: '英国' },
        { name: 'TUR', value: '法国' },
      ],

      icons: [
        {
          id: '1',
          url: 'url',
          text: '这是1',
          flag: '1'
        },
        {
          id: '2',
          url: 'url',
          text: '这是2',
          flag: '1'
        },
        {
          id: '3',
          url: 'url',
          text: '这是3',
          flag: '0'
        },
        {
          id: '4',
          url: 'url',
          text: '这是4',
          flag: '1'
        }
      ],
      success: 'ok'
    },
    formSubmit: function (e) {
      console.log('form发生了submit事件，携带数据为：', e.detail.value)
    },
    formReset: function () {
      console.log('form发生了reset事件')
    }
    ,
    checkboxChange: function (e) {
      console.log('checkbox发生change事件，携带value值为：', e.detail.value)
    }
    ,
    loadingTap: function(){
        this.setData({
          hidden: false
        });
        var that = this;
        setTimeout(function(){
          that.setData({
              hidden: true
          });
          that.update();
        }, 3000);
    }
,

    add: function (res) {
      this.setData({
        count: this.data.count + 1

      })
    },
    switch: function (e) {
      const length = this.data.icons.length
      for (let i = 0; i < length; ++i) {
        const x = Math.floor(Math.random() * length)
        const y = Math.floor(Math.random() * length)
        const temp = this.data.icons[x]
        this.data.icons[x] = this.data.icons[y]
        this.data.icons[y] = temp

      }
      this.setData({

        icons: this.data.icons
      })
    },
    addNumberToFront: function (e) {
      this.data.numberArray = [this.data.numberArray.length + 1].concat(this.data.numberArray)
      this.setData({
        numberArray: this.data.numberArray
      })

    },
    addToFront: function (e) {
      const length = this.data.icons.length
      this.data.icons = [{ id: length, text: 'zheshi' + length }].concat(this.data.icons)
      this.setData({
        icons: this.data.icons
      })
    }
















  }
)